<?php
@header("Content-Type:text/html;charset=utf-8");
@include_once("conn.php");
@include_once("common.php");

if(!(isset($_GET["id"]))){
    paramsErr();
}

$id=$_GET["id"];
$sql="select * from `goodslist` where id='${id}'";
$result=mysqli_query($conn,$sql);
$obj=array();
if($result){ // 判断查询的结果
    
    // $list = array();
    // while($item = mysqli_fetch_assoc($result)){  // 循环解析数据  有数据 => 继续解析,没有数据=> false => 跳出循环
    //     // 数据的预处理
    //    array_push($list,$item);
    // }
    $item=mysqli_fetch_assoc($result);
    if($item){
        $obj["status"] = true;
        $obj["msg"] = "success";
        
        $smallList=explode(",",$item["smallPicList"]);//将字符串拆分为数组，限制数量
        $item["smallPicList"]=array_splice($smallList,0,4);
        $bigList=explode(",",$item["bigPicList"]);
        $item["bigPicList"]=array_splice($bigList,0,4);
        $obj["list"]=$item;
    }


}else{
    $obj["status"] = false;
    $obj["msg"] = "sql语句有误";
    $obj["sql"] = $sql;
}
echo json_encode($obj);
?>